import("io", true)
	high = function(mychar){ if(mychar == "1" || mychar == "-" ) return 1; else return 0}
	low = function(mychar){ if(mychar == "0" || mychar == "-" ) return 1; else return 0}
  check1 = function(mychar){ if((high(mychar))&&(!low(mychar))) return true;	else return false;}
	check0 = function(mychar){ if((!high(mychar))&&(low(mychar))) return true;	else return false;}
	checkx = function(mychar){ if( mychar == "-" ) return true;	else return false;}
  equalx = function(exmycube, exx){ //exmycube and exx are "cube" datatype

		////print("Entering equalx")
		var exj = 0
		for(exj=0; exj < exmycube.length; exj++)
		{
			if(((check0(exx[exj])) && (check1(exmycube[exj]))) || ((check1(exx[exj])) && (check0(exmycube[exj]))))
				return false
		}
return true}
absorb_cover = File.Load("tautology.ls","rb").split("\n")
absorb_cover.splice(absorb_cover.length-1, 1)
temp_cube = absorb_cover[0]
z="-"
print("b4 "+temp_cube)
for(j=0; j<2; j++)
{
  if(!checkx(temp_cube[j])) //try to raise char from 1 or 0 to DC
  {
    var x=""
    x = temp_cube.split("")
    x[j]="-"
    temp_cube = ""
    temp_cube = x.join("")
    cofac = []
    for(k=0; k<absorb_cover.length; k++) //go over all remaining implicants
    {
      if(equalx(absorb_cover[k],temp_cube))
      {
      	cocube = "";
      	for(l=0; l<absorb_cover[k].length; l++)
      	{
      		print("Checkx " + checkx(temp_cube[l]))
      		if(checkx(temp_cube[l]))
      		{
      			cocube=cocube.concat(absorb_cover[k][l])
      		}
      		else
      		{
      			cocube=cocube.concat(z)
      		}
      	}
        print("j = " + 0 +" k= "+k+" Cocube is "+ cocube + " temp_cube is "+ temp_cube)
      	cofac.push(cocube); //create the cofactor based on the expanded implicant
      }
    } // end of the for that goes through all implicants
  }
}
